package vcp.gui.components;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.JobAttributes.DefaultSelectionType;

import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableStringConverter;

/**
 * VCP Scroll table, used in prohject for table representation
 *
 */
public class VCPScrollTable extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
    private DefaultTableModel dtm;
    private JTable table;
    private JScrollPane scrollPane;
    public VCPScrollTable(int rows,TableModel tmodel){
    	
    	dtm = (DefaultTableModel) tmodel;
        table = new JTable(dtm);
    	scrollPane = new JScrollPane(table);
    	scrollPane.getVerticalScrollBar();
    	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		setLayout(new BorderLayout());
		 scrollPane.setVerticalScrollBarPolicy(
	                JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	          
	     this.add(scrollPane, BorderLayout.CENTER);
    }
    
    public DefaultTableModel getDtm() {
		return dtm;
	}
	public void setDtm(DefaultTableModel dtm) {
		this.dtm = dtm;
	}
	public JTable getTable() {
		return table;
	}
	public void setTable(JTable table) {
		this.table = table;
	}

	public boolean isCellEditable(int row, int column) {
		// TODO Auto-generated method stub
		return false;
	}

	public ListSelectionModel getSelectionModel() {
		return getTable().getSelectionModel();
	}
}
